//
//  UIButton+Exienion.m
//  weibo-OC
//
//  Created by diyuyma on 16/2/28.
//  Copyright © 2016年 zhangkaiyun. All rights reserved.
//

#import "UIButton+Exienion.h"

@implementation UIButton (Exienion)


- (void)initWithTitle:(NSString *)title WithBackImage:(NSString *)backImage WithColor:(UIColor *)clolr WithImage:(NSString *)image WithSize:(CGFloat)size {
    
//   self = [super init];
    
    if (title != nil) {
        [self setTitle:title forState:UIControlStateNormal];
    }
    
    if (backImage != nil) {
        [self setBackgroundImage:[UIImage imageNamed:backImage] forState:UIControlStateNormal];
        [self setBackgroundImage:[UIImage imageNamed:[NSString stringWithFormat:@"%@_highlighted", backImage]] forState:UIControlStateHighlighted];
    }
    if (image != nil) {
        
        [self setImage:[UIImage imageNamed:image] forState:UIControlStateNormal];
    }
    
    if (size != 0) {
        
        self.titleLabel.font = [UIFont systemFontOfSize:size];
    }
    
    if (clolr != nil) {
        [self setTitleColor:clolr forState:UIControlStateNormal];
    }
    [self sizeToFit];
}

@end
